// JavaScript Document
var control = control || {};

(function(control){
	function show(){
		var node = control.leftNav.defaults.target;
		var target = node.target;
		var height = target.offsetHeight;
		if(!node.show){
			target.style.height = --height+"px";	
		}
		else{
			target.style.height = ++height+"px";	
		}
		
		if(height <=0){
			clearInterval(control.leftNav.defaults.timer);
			control.leftNav.defaults.timer = null;
			target.style.borderBottom = "1px #999 dashed";
		}
		else if(height>=node.height){
			clearInterval(control.leftNav.defaults.timer);
			control.leftNav.defaults.timer = null;
			target.style.borderBottom = "none";			
			target.style.height = node.height+"px";
		}
	}
	function init(className){
		var nodes = document.getElementsByClassName(className);
		var arr = [];
		var len = nodes.length;
		for(var i=0;i<len;i++){
			var n = nodes[i];
			var target = {};
			target.width = n.offsetWidth;
			target.height = n.offsetHeight;
			target.target = n;
			target.show = true;
			arr.push(target);
		}
		control.leftNav.defaults.nodes = arr;
	}
	control.show = function(id){
		var target = document.getElementById(id);
		
		var nodes = control.leftNav.defaults.nodes;
		if(!target||!nodes){
			return;
		}
		var len = nodes.length;
		for(var i =0;i<len;i++){
			var t = nodes[i];
			if(t.target == target){	
				if(control.leftNav.defaults.timer){
					break;	
				}		
				t.show = !t.show;
				control.leftNav.defaults.target = t;
				var timer = setInterval(show,5);
				control.leftNav.defaults.timer = timer;
				timer = null;
				break;	
			}	
		}	
	}
	control.leftNav = function(className){
		init(className);
	}	
	control.leftNav.defaults ={
		nodes:null,
		target:"",
		timer:null
	}
})(control)


/*function loadInfo(module){
	var searchButtom = document.getElementById("search");
	if(module == 'user'){
		var userName = document.getElementById("un").value;
		var userPlace = document.getElementById("up").value;
		var registerTime = document.getElementById("rt").value;
		searchButtom.option = userOption;			
		searchButtom.url = "/networkforum/control/user_control.do?userName="+userName+
							"&userPlace="+userPlace+"&registerTime="+registerTime;
	}
	
}
function searchInfo(){
	var searchButtom = document.getElementById("search");
	var url = searchButtom.url;
	var option = searchButtom.option;
	
	var myajax = getByAjax();
	myajax.init(null,"get",true);
	myajax.get(url+"&index=0&size=10",function(d){
		var data = toJson(d);
		//page.view('articleInner',article,articleOption);
		page.view("rightUlInner",data,option);
		
	});
	myajax = null;
}*/

var articleOption = {
	
}

// 遗落战境

function clearUlInner(){
	var ul = document.getElementById("rightUlInner");
	var module = ul.children[0];
	var header = ul.children[1];
	ul.innerHTML = "";
	ul.appendChild(module);
	ul.appendChild(header);
}
function scrollEvent(url,callBack,data){
	//添加scroll事件
	var param = {
		url:url,
		size:20,
		data:data,
		callBack:callBack,
		target:window.parent,
		containerId:"rightUlInner"
	}
	page.scrolls(param);
}